import rclpy

from rclpy.node import Node

from chapt4_interfaces.srv import FaceDetector 
import time
class Service(Node):
    def __init__(self,node_name):
        super().__init__(node_name)
        self.get_logger().info(f"{node_name} 服务端启动")
        # 创建服务
        self.service=self.create_service(FaceDetector,'stu_service',self.service_callback)

    #接受服务回调函数 服务端
    def service_callback(self,request,response):
        self.get_logger().info(f"传递的 number参数为:{request.number}")

        # 返回的参数
        response.use_time=time.time()
        response.name="heizige "+str(request.number)
        response.arr=[1,2,3,4,5]

        return response #必须返回

def main():
    rclpy.init()
    node=Service('stu_service')
    
    rclpy.spin(node)

    rclpy.shutdown()